package com.qdaily.ui.net.entity;

import android.os.Parcel;
import android.os.Parcelable;
import com.qdaily.ui.net.model.CommentChildFeed;
import com.qdaily.ui.net.model.CommentMeta;
import com.qdaily.ui.net.model.SendCommentFeeds;

/**
 * 发送评论，返回的实体
 * Created with IntelliJ IDEA.
 * User: Felix
 * Date: 4/29/15
 * Time: 15:33
 * QQ:74104
 * Email:lovejiuwei@gmail.com
 */
public class SendCommentEntity extends BaseEntity implements Parcelable {
    private SendCommentFeeds response;

    public SendCommentFeeds getResponse() {
        return response;
    }

    public void setResponse(SendCommentFeeds response) {
        this.response = response;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeParcelable(this.response, flags);
    }

    public SendCommentEntity() {
    }

    private SendCommentEntity(Parcel in) {
        this.response = in.readParcelable(SendCommentFeeds.class.getClassLoader());
    }

    public static final Parcelable.Creator<SendCommentEntity> CREATOR = new Parcelable.Creator<SendCommentEntity>() {
        public SendCommentEntity createFromParcel(Parcel source) {
            return new SendCommentEntity(source);
        }

        public SendCommentEntity[] newArray(int size) {
            return new SendCommentEntity[size];
        }
    };

    @Override
    public String toString() {
        return "SendCommentEntity{" +
                "response=" + response +
                '}';
    }

    public CommentMeta translationParentModel() {
        return getResponse().getComment();
    }

    public CommentChildFeed translationChildModel() {
        CommentChildFeed commentChildFeed = new CommentChildFeed();
        commentChildFeed.setId(response.getId());
        commentChildFeed.setPublish_time(response.getComment().getPublish_time());
        commentChildFeed.setAuthor(response.getComment().getAuthor());
        commentChildFeed.setContent(response.getComment().getContent());
        return commentChildFeed;
    }
}
